<?php
declare (strict_types = 1);
namespace app\promotion\service;

use think\facade\Request;
use app\common\service\BaseService;
use app\common\exception\LogicException;
use app\promotion\logic\PromotionTuan;


/**
 * 团购接口处理类
 */
class Tuan extends BaseService
{

	/**
	 * 发起拼团
	 * Author 亓官雨树<lucky.max@foxmail.com>
	 * Date 2021-04-14
	 * @return [type] [description]
	 */
	public function createUserTuan()
	{
		$param = Request::post();
		
		$data = app(PromotionTuan::class)->createUserTuan($param);

		return $this->parseToData($data, 1, '开团成功');
	}

	/**
	 * 加入拼团
	 * Author 亓官雨树<lucky.max@foxmail.com>
	 * Date 2021-04-14
	 * @return [type] [description]
	 */
	public function joinUserTuan()
	{
		$param = Request::post();
		
		$data = app(PromotionTuan::class)->joinUserTuan($param);

		return $this->parseToData($data, 1, '入团成功');
	}

	/**
	 * 获取团购详情
	 * Author 亓官雨树<lucky.max@foxmail.com>
	 * Date 2021-04-15
	 * @return [type] [description]
	 */
	public function getUserTuanDetail()
	{
		$param = Request::get();
		
		$data = app(PromotionTuan::class)->getUserTuanDetail($param);

		return $this->parseToData($data, 1, '获取成功');
	}

	/**
	 * 获取课程已开团列表
	 * Author 亓官雨树<lucky.max@foxmail.com>
	 * Date 2021-04-20
	 * @return [type] [description]
	 */
	public function getCourseTuanList()
	{
		$param = Request::get();
		
		$data = app(PromotionTuan::class)->getCourseTuanList($param);

		return $this->parseToData($data, 1, '获取成功');
	}
}